Add the ability to avoid page-breaks in the middle of elements.#111
Add the ability to avoid page-breaks in the middle of elements.#111Ranger1230 wants to merge 1 commit intoeKoopmans:developfrom Ranger1230:develop
Conversation
adbahrani
left a comment
There was a problem hiding this comment.
source need to change to this.prop.container
eKoopmans
left a comment
There was a problem hiding this comment.
Hi @Ranger1230, thank you very much! It's a simple and useful solution. There are currently 4 pagebreak PRs, I'm looking into combining them into one. Thanks again!
| }, this); | ||
|
|
||
| // Enable avoiding page-breaks in the middle of elements. | ||
| var pageBreakAvoids = source.querySelectorAll('.html2pdf__page-break-avoid'); |
There was a problem hiding this comment.
As @adbahrani pointed out, source should be this.prop.container.
|
How did you achieve this? Can I implement this solution to paragraphs and input fields instead of images? |
|
Hi, closing as these features were combined into #153. Thanks again for the contribution, I'll add you as a contributor on the readme! P.S. @Greensahil, check the readme for the page-break feature added in v0.9.1. It can avoid page-breaks on whatever you want, including "everything" ( |
I added the ability to provide the class
html2pdf__page-break-avoidon an element that you would like to try and avoid breaking in the middle of if possible. This is useful for images so you don't have half the image on one page and half the image on the next. This will insert a div with a height computed (just like the logic forhtml2pdf__page-break) that will cause a page break to be put in before the element.This will only help to avoid page breaks, if an element with this class is larger than 1 page it will still have a page break in it.